const express = require("express");
const app = express();

app.use((req, res, next) => {
    console.log("有人请求服务器1");
    next();
});

app.get("/students", (req, res) => {
    const students = [
        {
            id: "001",
            name: "tom",
            age: 18,
        },
        {
            id: "002",
            name: "jerry",
            age: 19,
        },
        {
            id: "003",
            name: "tony",
            age: 120,
        },
    ];
    res.send(students);
});

app.listen(5000, (error) => {
    if (!error) {
        console.log(
            "服务器1成功去启动，请求学生信息地址为：http://localhost:5000/students"
        );
    }
});
